// 处理用户登录逻辑的

const db =require("../lib/db")

function userLogin(userName,userpwd){
    return new Promise((resolve,reject)=>{
   let sql ="select * from enroll where userName='" + userName +"'";

   db.querySql(sql).then(data=>{
    console.log(data)
    if(data.length == 0){
        // console.log("用户不存在")
           resolve(501)
    }else{
        if(data[0].userPassword == userpwd){
            resolve(data[0])
        }else{
            resolve(502)
        }
    }
   })
 })
}

// 导出
module.exports = userLogin
